home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML Instance.sea / XML Instance / Required / plugins / HTMLWindow.jar / horst / HistoryManager.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-03-18  |  1.5 KB  |  55 lines

  1. package horst;
  2.  
  3. import java.net.URL;
  4. import java.util.Vector;
  5.  
  6. public class HistoryManager {
  7.    Vector m_urls = new Vector();
  8.    int m_ptr = -1;
  9.  
  10.    public void add(URL u) {
  11.       if (this.m_ptr == this.m_urls.size() - 1) {
  12.          this.m_urls.addElement(u);
  13.          this.m_ptr = this.m_urls.size() - 1;
  14.       } else {
  15.          ++this.m_ptr;
  16.          this.m_urls.insertElementAt(u, this.m_ptr);
  17.  
  18.          for(int i = this.m_urls.size() - 1; i > this.m_ptr; --i) {
  19.             this.m_urls.removeElementAt(i);
  20.          }
  21.       }
  22.  
  23.    }
  24.  
  25.    public URL back() {
  26.       if (this.m_ptr > 0 && this.m_ptr - 1 < this.m_urls.size()) {
  27.          --this.m_ptr;
  28.          return (URL)this.m_urls.elementAt(this.m_ptr);
  29.       } else {
  30.          return null;
  31.       }
  32.    }
  33.  
  34.    public boolean canMoveBack() {
  35.       return this.m_ptr > 0;
  36.    }
  37.  
  38.    public boolean canMoveForward() {
  39.       return this.m_ptr + 1 < this.m_urls.size();
  40.    }
  41.  
  42.    public void clear() {
  43.       this.m_urls.removeAllElements();
  44.    }
  45.  
  46.    public URL forward() {
  47.       if (this.m_ptr + 1 < this.m_urls.size()) {
  48.          ++this.m_ptr;
  49.          return (URL)this.m_urls.elementAt(this.m_ptr);
  50.       } else {
  51.          return null;
  52.       }
  53.    }
  54. }
  55.